<template>
	<!-- 滑动标签 -->
	<view class="uni-tab-bar">
		<scroll-view scroll-x class="uni-swiper-tab">
			<view class="swiper-tab-list" v-for="(tab,index) in tabBars" :key="tab.id" :class="{'active':tabIndex == index}" @tap="tabTap(index)">
				{{tab.name}}
				<view class="swiper-tab-line"></view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	/*
	 * swiperTabbar 首页滑动标签
	 * @description 用于首页滑动标签
	 * @author MrThinco
	 * @property {Number} tabIndex 选中索引
	 * @property {Array} tabBars 标签栏数据
	 */
	export default {
		props:{
			// 标签栏
			tabIndex:Number, // 选中索引
			tabBars:Array 
		},
		methods: {
			// tabbar点击
			tabTap(index) {
				this.$emit('tabTap',index);
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 复用了common/css/uni.css中class
	 .uni-tab-bar {
		 .uni-swiper-tab {
			 height: 100rpx;
		 }
		 .swiper-tab-list {
		 	 color: map-get($behaviour-color,info);
		 	 font-weight: 700;
		 }
		 .active {
			 color: map-get($theme-color,green);
			 .swiper-tab-line {
				 border: 4rpx solid map-get($theme-color,green);
				 width: 70rpx;
				 margin: auto;
				 border-radius: 20rpx;
			 }
		 }
	 }
</style>
